package teacher;

import lombok.extern.java.Log;
import org.apache.hadoop.conf.Configuration;
import org.apache.hadoop.fs.FileSystem;
import org.apache.hadoop.fs.Path;
import org.apache.hadoop.io.IntWritable;
import org.apache.hadoop.io.LongWritable;
import org.apache.hadoop.io.NullWritable;
import org.apache.hadoop.io.Text;
import org.apache.hadoop.mapreduce.Job;
import org.apache.hadoop.mapreduce.Mapper;
import org.apache.hadoop.mapreduce.lib.input.FileInputFormat;
import org.apache.hadoop.mapreduce.lib.output.FileOutputFormat;
import pojo.Movie;
import system.impl.MovieSystemImpl;
import tool.FileUtil;
import tool.LogCat;
import tool.ReaderUtil;

import java.io.*;
import java.util.*;

// 合并电影文件和评分文件
public class DataAddNew {

    public static void main(String[] args) {

        // 创建一个 MovieSystemImpl 实例并设置一些状态
        MovieSystemImpl movieSystem = new MovieSystemImpl();
        // ...（设置状态）

        // 将对象序列化到文件
        movieSystem.serializeToFile(Config.SYSTEM_PATH);

        // 从文件反序列化对象
        MovieSystemImpl deserializedMovieSystem = MovieSystemImpl.deserializeFromFile(Config.SYSTEM_PATH);
        if (deserializedMovieSystem != null) {
            System.out.println("Deserialized MovieSystemImpl instance:");
            // ...（打印或使用反序列化后的对象）
            deserializedMovieSystem.test();
            System.out.println("可以继续下一步了");
        } else {
            System.out.println("Failed to deserialize the MovieSystemImpl instance.");
        }

        LogCat.line();
        String s = FileUtil.readFile(Config.MOVIE_PATH);
        String[] split = s.split("\n");
        for (String string : split) {
            System.out.println(string);
            Movie movies = ReaderUtil.readLine2Movie(string);
            System.out.println(movies);
            LogCat.line();

        }

    }
    /*public static void main(String[] args) {
        //连接文件路径
        String userPath=Config.USER_PATH;
        String addPath=Config.TEMP_PATH+"\\part-m-00000";

        String s = FileUtil.readFile(addPath);
        LogCat.d(s);
        LogCat.line();
        //获取用户列表
        String s1 = FileUtil.readFile(userPath);
        LogCat.d(s1);
        LogCat.line();
    }*/
}